#!/usr/bin/perl -w

$print = "$ARGV[0]";
$test = "error";
@array = ();
$a = 0;

open $file, "<", "HostingPackage.txt";

while ($line = <$file>) {   # checks all lines in file

        if($line =~ /^\s*(\d{4})
			\s*\|\s*(\d+)
			\s*\|\s*([.\S]*)
			\s*\|\s*(.*)
			\|\s*(.*)
			\|\s*(.*)
			\|\s*(.*)
			\|\s*(.*)
			\|\s*(.*)
			\|\s*(.*)
			/x) {
		if($1) { $test = $1; $array[$a]{"HostingID"} = $1."\n"; }
		if($2) { $array[$a]{"SortOrder"} = $2."\n"; }
		if($3) { $array[$a]{"URL"} = $3."\n"; }
		if($4) { $array[$a]{"Title"} = $4."\n"; }
		if($5) { $array[$a]{"Comment"} = $5."\n"; }
		if($6) { $array[$a]{"Setup fee"} = $6."\n"; }
		if($7) { $array[$a]{"Monthly fee"} = $7."\n"; }
		if($8) { $array[$a]{"Description"} = $8."\n"; }
		if($9) { $array[$a]{"Service List"} = $9."\n"; }
		$a++;
		}

}

if ($test =~ "error") { print "ErrorCode626"; }

elsif (!($array[$print])) { print "ErrorCode627\n"; }

else { %hash = %{$array[$print]}; 
	foreach $key (sort keys %hash) {
	     print "$key: $hash{$key}";
	}} 

close $file;

exit(5);
